package mc

import (
	"gitee.com/dreamwood/ez-go/db/mgo"
)

const (
	CarEventNew           = "pm.CarNew"
	CarEventBeforeCreate  = "pm.CarBeforeCreate"
	CarEventBeforeUpdate  = "pm.CarBeforeUpdate"
	CarEventBeforeSave    = "pm.CarBeforeCreate pm.CarBeforeUpdate"
	CarEventAfterCreate   = "pm.CarAfterCreate"
	CarEventAfterUpdate   = "pm.CarAfterUpdate"
	CarEventAfterSave     = "pm.CarAfterCreate pm.CarAfterUpdate"
	CarEventDelete        = "pm.CarDelete"
	CarAccessControlEvent = "pm.CarAccessControl"
)

func GetCarConfig() *mgo.DocConfig {
	return Car_Config
}

var Car_Config *mgo.DocConfig

func init() {
	Car_Config = NewCarConfig()
}
func NewCarConfig() *mgo.DocConfig {
	return &mgo.DocConfig{
		ContainerKey: "pm.Car",
		Fields: []string{
			"house", "number", "note",
		},
		RelationFields: []string{
			"house",
		},
		RelationConfigs: map[string]*mgo.DocRelation{
			"house": {
				Config:     GetHouseConfig,
				DocName:    "House",
				JoinType:   "MM",
				KeyInside:  "houseId",
				KeyOutSide: "id",
			},
		},
		FieldFilter: map[string]*mgo.DocFieldFilter{
			"default": {
				Select: []string{},
				Omit:   []string{},
			},
		},
	}
}
